using System;
namespace BMC.ARSystem
{
	public class TimeOfDayValue
	{
		private TimeSpan data;
		public static int MAX_SECONDS_IN_DAY = 86400;
		public int Hours
		{
			get
			{
				return this.data.get_Hours();
			}
			set
			{
				this.Initialize(value, this.Minutes, this.Seconds);
			}
		}
		public int Minutes
		{
			get
			{
				return this.data.get_Minutes();
			}
			set
			{
				this.Initialize(this.Hours, value, this.Seconds);
			}
		}
		public int Seconds
		{
			get
			{
				return this.data.get_Seconds();
			}
			set
			{
				this.Initialize(this.Hours, this.Minutes, value);
			}
		}
		public int TotalSeconds
		{
			get
			{
				return (int)this.data.get_TotalSeconds();
			}
			set
			{
				this.data = new TimeSpan(value / 3600, value % 3600 / 60, value % 60);
			}
		}
		public TimeOfDayValue(uint hours, uint minutes, uint seconds)
		{
			this.Initialize((int)hours, (int)minutes, (int)seconds);
		}
		private void Initialize(int hours, int minutes, int seconds)
		{
			if (hours > 24 || minutes >= 60 || seconds >= 60)
			{
				throw new ARException(string.Format("TimeOfDayValue value must values in this range [Hours (0-23), Minutes (0-59), Seconds (0-59)] but specified: ({0},{1},{2}))", hours, minutes, seconds));
			}
			this.data = new TimeSpan(hours, minutes, seconds);
		}
		public TimeOfDayValue(int elapsedSeconds)
		{
			if (elapsedSeconds > TimeOfDayValue.MAX_SECONDS_IN_DAY)
			{
				throw new ARException(string.Format("TimeOfDayValue value must values in this range [0-{0}] but specified: ({1}))", TimeOfDayValue.MAX_SECONDS_IN_DAY, elapsedSeconds));
			}
			this.data = new TimeSpan(0, 0, elapsedSeconds);
		}
		public override int GetHashCode()
		{
			return this.Hours.GetHashCode() ^ this.Minutes.GetHashCode() ^ this.Seconds.GetHashCode();
		}
		public override bool Equals(object obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (base.GetType() != obj.GetType())
			{
				return false;
			}
			TimeOfDayValue timeOfDayValue = (TimeOfDayValue)obj;
			return timeOfDayValue.Hours == this.Hours && timeOfDayValue.Minutes == this.Minutes && timeOfDayValue.Seconds == this.Seconds;
		}
		public bool Equals(TimeOfDayValue obj)
		{
			return obj != null && (obj.Hours == this.Hours && obj.Minutes == this.Minutes) && obj.Seconds == this.Seconds;
		}
		public bool Equals(TimeSpan obj)
		{
			return obj != null && this.data.Equals(obj);
		}
		public static bool operator ==(TimeOfDayValue v1, TimeOfDayValue v2)
		{
			return v1.Equals(v2);
		}
		public static bool operator !=(TimeOfDayValue v1, TimeOfDayValue v2)
		{
			return !(v1 == v2);
		}
		public override string ToString()
		{
			return string.Format("{0}:{5}{1}:{4}{2} {3}", new object[]
			{
				(this.data.get_Hours() <= 12) ? this.data.get_Hours() : (this.data.get_Hours() % 12),
				(this.data.get_Minutes() < 10) ? "0" : "",
				this.data.get_Seconds(),
				(this.data.get_Hours() <= 12) ? "AM" : "PM",
				(this.data.get_Seconds() < 10) ? "0" : "",
				this.data.get_Minutes()
			});
		}
	}
}
